<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:msds="http://ehs-info.com/msds" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:param name="index" select="document('../XmlData/index.xml')/index"/>
	<xsl:param name="CompanyDB" select="document('../XmlData/CompanyDB.xml')/msds:companyDB"/>
	<xsl:template match="/msds:substanceDB">
		<html xmlns="http://www.w3.org/1999/xhtml" lang="sv" xml:lang="sv">
			<head>
				<title>Ämnen och var dom används</title>
				<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
				<meta http-equiv="Content-Language" content="sv"/>
				<style type="text/css" media="screen">@import "Produkter/Styles/general.css";</style>
				<link rel="stylesheet" type="text/css" media="print" href="Produkter/Styles/printgeneral.css"/>
			</head>
			<body>
				<xsl:for-each select="msds:substance">
					<xsl:sort select="msds:name[1]"/>
					<div id="substanceSection">
						<a id="{@id}" name="{@id}">
							<h1>
								<xsl:value-of select="msds:name[1]"/>
							</h1>
						</a>
						<xsl:if test="$index/product/substances/substance[@id=current()/@id]">
							<p/>
							<div id="reportTable">
								<table>
									<tbody>
										<tr>
											<td>Company</td>
											<td>Product Name</td>
										</tr>
										<xsl:for-each select="$index/product/substances/substance[@id=current()/@id]">
											<xsl:sort select="../../@companyId"/>
											<tr>
												<td>
													<a href="CompanyDB.xml#{../../@companyId}">
														<xsl:value-of select="$CompanyDB/msds:company[@id=current()/../../@companyId]/msds:name"/>
													</a>
												</td>
												<td>
													<a href="Produkter/{../../@productId}.xml">
														<xsl:value-of select="../../@productName"/>
													</a>
												</td>
											</tr>
										</xsl:for-each>
									</tbody>
								</table>
							</div>
						</xsl:if>
					</div>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
